home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / lib / util / compress.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  645 b   |  27 lines

  1. #include "util.h"
  2. /* compress-out redundant linear white space & strip trailing lwsp */
  3.  
  4. char *
  5.     compress (fromptr, toptr)
  6. register char *fromptr,
  7.           *toptr;
  8. {
  9.     register char   chr;
  10.  
  11.     chr = ' ';                    /* init to skip leading spaces  */
  12.     while ((*toptr = *fromptr++) != '\0')
  13.     {                             /* convert newlines and tabs to */
  14.     if (isspace (*toptr))
  15.     {                         /* only save first space      */
  16.         if (chr != ' ')
  17.         *toptr++ = chr  = ' ';
  18.     }
  19.     else
  20.         chr = *toptr++;
  21.     }
  22.  
  23.     if (chr == ' ')               /* remove trailing space if any */
  24.     *--toptr = '\0';
  25.     return (toptr);
  26. }
  27.